package com.diaohw.module.system.controller;


import com.diaohw.module.system.obj.query.LoginLogQuery;
import com.diaohw.module.system.obj.vo.LoginLogVo;
import com.diaohw.module.system.service.AccountLoginLogService;
import com.diaohw.platform.common.obj.page.PageResultVo;
import com.diaohw.platform.remote.auth.obj.bo.LoginLogBO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 用户登录日志 前端控制器
 * </p>
 *
 * @author D-Hw
 * @since 2024-07-08
 */
@Tag(name = "登录日志管理")
@RestController
@RequestMapping("/login-log")
public class LoginLogController {

    @Resource
    AccountLoginLogService service;

    @PostMapping
    @Operation(summary = "添加登录日志")
    public Boolean create(@RequestBody LoginLogBO log) {
        return service.create(log);
    }
    @DeleteMapping("/{id}")
    @Operation(summary = "删除")
    public Boolean delete(@PathVariable("id") String id) {
        return service.delete(id);
    }

    @GetMapping("/{id}")
    @Operation(summary = "依据ID查看信息")
    public LoginLogVo detail(@PathVariable("id") String id) {
        return service.detail(id);
    }

    @GetMapping
    @Operation(summary = "查询列表")
    public List<LoginLogVo> all(LoginLogQuery query) {
        return service.findByList(query);
    }

    @GetMapping("/page")
    @Operation(summary = "分页查看")
    public PageResultVo<LoginLogVo> page(LoginLogQuery query) {
        return service.findByPage(query);
    }

}
